#include<iostream>
#include<vector>
#include<string>
#include<stdio.h>
#include<algorithm>
using namespace std;
void split(string src, string delim, vector<string> &res){
    int last=0;
    int index=src.find_first_of(delim, last);
    while (index!=string::npos){
        res.push_back(src.substr(last, index-last));
        last=index+1;
        index=src.find_first_of(delim, last);
    }
    if (src.length()-last>0){
        res.push_back(src.substr(last,src.length()-last));
    }
}
class People{
public:
    int arrive_time;
    int waiting_time;
    int process_time;
    People(int art, int p){
        this->arrive_time=art;
        this->process_time=p;
        this->waiting_time = 0;
    }
};
bool mysort(const People &x, const People &y){
    if (x.arrive_time != y.arrive_time)
        return x.arrive_time < y.arrive_time;
    else
        return x.waiting_time > y.waiting_time;
}
int main(void){
    int N,K;
    cin>>N>>K;
    int i=0;
    vector<People> v;
    while (i<N){
        string t;
        int p;
        cin>>t>>p;
        vector<string> tv;
        split(t,":",tv);
        int hour=atoi(tv[0].c_str());
        int minute=atoi(tv[1].c_str());
        int second=atoi(tv[2].c_str());
        int arrt = hour*3600+minute*60+second;
        if (arrt <=17*3600){
            if (p>60) p = 60;
            People people = People(arrt, p*60);
            int wt = 8*3600 - arrt;
            if (wt>0){
                people.waiting_time = wt;
                people.arrive_time = 3600*8;
            }
            v.push_back(people);
        }
        i++;
    }

    sort(v.begin(), v.end(), mysort);

    int windows_left_seconds[K]={0};
    int last_arrive_time=3600*8;

    for(int i=0;i<v.size();i++){
        People &p = v[i];
        int arrive_time = p.arrive_time;
        int process_time = p.process_time;

        for(int j=0;j<K;j++){
            if(windows_left_seconds[j]>0){
                windows_left_seconds[j] -= arrive_time - last_arrive_time;
            }
        }
        bool has_empty = false;
        for (int j=0;j<K;j++){
            if (windows_left_seconds[j] <= 0){
                has_empty = true;
                windows_left_seconds[j] = process_time;
                last_arrive_time = arrive_time;
                break;
            }
        }
        if (!has_empty){
            int min_left_seconds = 86401;//3601 is not enough
            int empty_windows = -1;
            for(int j=0;j<K;j++){
                if (windows_left_seconds[j]<min_left_seconds){
                    min_left_seconds = windows_left_seconds[j];
                    empty_windows=j;
                }
            }
            windows_left_seconds[empty_windows] += process_time;
            last_arrive_time = arrive_time;
            p.waiting_time += min_left_seconds;
        }
    }

    int total_waiting_time = 0;
    for(int i=0;i<v.size();i++){
        total_waiting_time+=v[i].waiting_time;
    }

    printf("%.1f\n",(float)total_waiting_time/60/v.size());

    return 0;
}
